package com.eden.websocket.service.impl;

import com.eden.common.core.text.Convert;
import com.eden.common.utils.DateUtils;
import com.eden.websocket.domain.ChatList;
import com.eden.websocket.mapper.ChatListMapper;
import com.eden.websocket.service.IChatListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 聊天消息列Service业务层处理
 *
 * @author jiaoyang
 * @date 2021-03-06
 */
@Service(value = "chatListServiceImpl")
public class ChatListServiceImpl implements IChatListService {
    @Autowired
    private ChatListMapper chatListMapper;

    /**
     * 查询聊天消息列
     *
     * @param chatId 聊天消息列ID
     * @return 聊天消息列
     */
    @Override
    public ChatList selectChatListById(Long chatId) {
        return chatListMapper.selectChatListById(chatId);
    }

    /**
     * 查询聊天消息列列表
     *
     * @param chatList 聊天消息列
     * @return 聊天消息列
     */
    @Override
    public List<ChatList> selectChatListList(ChatList chatList) {
        return chatListMapper.selectChatListList(chatList);
    }

    /**
     * 新增聊天消息列
     *
     * @param chatList 聊天消息列
     * @return 结果
     */
    @Override
    public int insertChatList(ChatList chatList) {
        chatList.setCreateTime(DateUtils.getNowDate());
        return chatListMapper.insertChatList(chatList);
    }

    /**
     * 修改聊天消息列
     *
     * @param chatList 聊天消息列
     * @return 结果
     */
    @Override
    public int updateChatList(ChatList chatList) {
        chatList.setUpdateTime(DateUtils.getNowDate());
        return chatListMapper.updateChatList(chatList);
    }

    /**
     * 删除聊天消息列对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteChatListByIds(String ids) {
        return chatListMapper.deleteChatListByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除聊天消息列信息
     *
     * @param chatId 聊天消息列ID
     * @return 结果
     */
    @Override
    public int deleteChatListById(Long chatId) {
        return chatListMapper.deleteChatListById(chatId);
    }

    @Override
    public int deleteChatList(ChatList chatList) {
        return chatListMapper.deleteChatList(chatList);
    }
}